#!/bin/bash 

PORT=9002
cd `dirname $0`  
#当前路径  
BIN_DIR=`pwd`  
echo $BIN_DIR  
#nohup node $BIN_DIR/app.js &

APP_PID=`netstat -ntlp |grep $PORT |awk  '{print $7}' |awk -F '/' '{print $1}'` 
#echo $APP_PID
#APP_PID不为空，说明应用已启动，直接退出  
if [ -n "$APP_PID" ]; then  
    echo "ERROR: The $SERVER_NAME already started!"  
    echo "PID: $APP_PID"  
    exit 1  
fi

nohup npm run dev  &
